<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue-2.4.0.js"></script>
    <link rel="stylesheet" href="./lib/bootstrap-3.3.7.css">
</head>

<body>
    <div id="app">
        <p>{{ msg | msgFormat('12','123') }}</p>
    </div>
    <script>
        //定义一个Vue的全局过滤器，名字叫做msgFormat
        Vue.filter('msgFormat', function (msg, arg1, arg2) {
            return msg.replace(/单纯/g, arg1 + arg2)
        })
        var vm = new Vue({
            el: "#app",
            data: {
                msg: '曾经的我，也是一个单纯的少年，单纯的我，傻傻的问，谁是世界上最单纯的男人'
            },
            methods: {

            },
            filters: {
                msgFormat: function (msg, arg1, arg2) {
                    return msg.replace(/单纯/g, arg1 + arg2)

                }
            }
        })
    </script>
</body>

</html>